//
//  MassgeViewModelVC.m
//  YZZX
//
//  Created by Easaa on 15/4/23.
//  Copyright (c) 2015年 Easaa. All rights reserved.
//

#import "MassgeViewModelVC.h"
#import "ButtonControlModelView.h"
#import "AdvisoryRegistrationView.h"
#import "MassgeTheFont.h"
#import "CommentListModelVC.h"

#import "NJKWebViewProgress.h"
#import "NJKWebViewProgressView.h"
//报名、咨询
#import "ActivitiesEntranceVC.h"
#import "AdvisoryForVC.h"

@interface MassgeViewModelVC ()<HXHttpRequestDelegate,UIScrollViewDelegate,UIWebViewDelegate,MassgeTheFontDelegate,UIGestureRecognizerDelegate>
{
    HXHttpRequest   *_httpRequest;
    UIView          *bgheadview;    //标题view
    UIView          *TabbarView;    //下边的工具栏
    UIWebView       * MassgeWebView;
    float      _textFontSize;
    
    UIScrollView        *_bgscrollView;//底层
    UIView          *viewbg;
}

@end

@implementation MassgeViewModelVC

-(id)initWithEstablish:(YZCellMassgeModel *)catemodel
{
    self = [super init];
    if(self)
    {
        self.DataMassgeModel = catemodel;
        self.title = @"详情";
        
        
    }

    return self;
}



-(void)creatViewAndContorller
{
    
   // viewbg  =[[UIView alloc]initWithFrame:CGRectMake(0, 0, Dev_ScreenWidth, Dev_ScreenHeight-64-49)];
    //[self.view addSubview:viewbg];
    

    _bgscrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, Dev_ScreenWidth, Dev_ScreenHeight-64-49)];
    _bgscrollView.delegate = self;
    //_bgscrollView.contentSize = CGSizeMake(Dev_ScreenWidth*arryDataNav.count, Dev_ScreenHeight-64-30);
    _bgscrollView.bounces = YES;
    //[_bgscrollView setPagingEnabled:YES];            //翻页形式
    //[_bgscrollView setShowsHorizontalScrollIndicator:NO];   //滚动条
    [self.view addSubview:_bgscrollView];

    
    //下边的工具栏
   TabbarView = [[UIView alloc]initWithFrame:CGRectMake(0, Dev_ScreenHeight-49-64, Dev_ScreenWidth, 49)];
    TabbarView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:TabbarView];
    //TabbarView.backgroundColor =[UIColor redColor];
    
    
    
    if([self.DataMassgeModel.CateId isEqualToString:@"1"])
    {
        //字体大小
        AdvisoryRegistrationView  *TabbarButFont = [[AdvisoryRegistrationView alloc]initWithButton:CGRectMake(0, 0, TabbarView.frame.size.width/2, TabbarView.frame.size.height)];
        TabbarButFont.tag = 0;
        [TabbarButFont addTarget:self action:@selector(AdvisorySelectorFantion:) forControlEvents:UIControlEventTouchUpInside];
        [TabbarView addSubview:TabbarButFont];
        //TabbarButFont.backgroundColor =[UIColor greenColor];
        TabbarButFont.imageViews.image = [UIImage imageNamed:@"Activities_zixun@2x.png"];
        TabbarButFont.lableview.text =@"咨询";
        
        //评论
        AdvisoryRegistrationView  *TabbarComments = [[AdvisoryRegistrationView alloc]initWithButton:CGRectMake( TabbarView.frame.size.width/2, 0, TabbarView.frame.size.width/2, TabbarView.frame.size.height)];
        TabbarComments.tag = 1;
        [TabbarComments addTarget:self action:@selector(AdvisorySelectorFantion:) forControlEvents:UIControlEventTouchUpInside];
        [TabbarView addSubview:TabbarComments];
        //TabbarComments.backgroundColor =[UIColor greenColor];
        TabbarComments.imageViews.image = [UIImage imageNamed:@"Activities_baoming@2x.png"];
        TabbarComments.lableview.text =@"报名";
    

    
    }else
    {
        //字体大小
        ButtonControlModelView  *TabbarButFont = [[ButtonControlModelView alloc]initWithButton:CGRectMake(0, 0, TabbarView.frame.size.width/2, TabbarView.frame.size.height)];
        TabbarButFont.tag = 0;
        [TabbarButFont addTarget:self action:@selector(TabbarSelectorFantion:) forControlEvents:UIControlEventTouchUpInside];
        [TabbarView addSubview:TabbarButFont];
        //TabbarButFont.backgroundColor =[UIColor greenColor];
        TabbarButFont.imageViews.image = [UIImage imageNamed:@"icon_fontsize.png"];
        
        
        //评论
        ButtonControlModelView  *TabbarComments = [[ButtonControlModelView alloc]initWithButton:CGRectMake( TabbarView.frame.size.width/2, 0, TabbarView.frame.size.width/2, TabbarView.frame.size.height)];
        TabbarComments.tag = 1;
        [TabbarComments addTarget:self action:@selector(TabbarSelectorFantion:) forControlEvents:UIControlEventTouchUpInside];
        [TabbarView addSubview:TabbarComments];
        //TabbarComments.backgroundColor =[UIColor greenColor];
        TabbarComments.imageViews.image = [UIImage imageNamed:@"icon_comment.png"];
    
    
    }
        

    
    
    
    
    
    
    
    
    MassgeWebView=[[UIWebView alloc] initWithFrame:CGRectZero];
    MassgeWebView.delegate=self;

    //MassgeWebView.dataDetectorTypes=UIDataDetectorTypeNone;
    MassgeWebView.frame= CGRectMake(0, 0, Dev_ScreenWidth, 0);
    MassgeWebView.scrollView.delegate = self;
    MassgeWebView.scrollView.alwaysBounceVertical = NO;
    MassgeWebView.scrollView.bounces = NO;
    MassgeWebView.scrollView.showsVerticalScrollIndicator = NO;
    [_bgscrollView addSubview:MassgeWebView];
 
    //********************************************字体大小样式设置****************************************

    
    //拿到设置字体大小设置
    NSUserDefaults *UserDefaultSize =[NSUserDefaults standardUserDefaults];
    _textFontSize = [UserDefaultSize floatForKey:YZZX_Font_Size];
    
    
    NSString *temstr;//只要是img标签都限定大小
    NSString *fontString;
    NSString *htmlString1;
    if(![self.DataMassgeModel.CateId isEqualToString:@"57"])
    {
        temstr=@"<style type=\"text/css\">img{max-width:100%;height:auto;} </style>";//只要是img标签都限定大小
        
        fontString = [NSString stringWithFormat:@"<style type=\"text/css\">*{-webkit-user-select: none;line-height:30px;font-size:%fpx; } </style>", _textFontSize];
        
        htmlString1 = [NSString stringWithFormat:@"%@%@%@",temstr, fontString, self.Content];//设置大小
    }else if ([self.DataMassgeModel.CateId isEqualToString:@"57"])
    {
        temstr = @"";
        fontString =@"";
        
        htmlString1 = [NSString stringWithFormat:@"%@%@%@",temstr, fontString, self.Content];//设置大小
    }
    
   // [_contentWebView loadHTMLString:htmlString1 baseURL:nil]
    
    [MassgeWebView loadHTMLString:htmlString1 baseURL:[NSURL URLWithString:@"http://www.hellomommy.cn/"]];
   
//     ScrollBackground.contentSize = CGSizeMake(Dev_ScreenWidth, Dev_ScreenHeight-64);
    
     //********************************************字体大小样式设置****************************************
   
    
//    
//    UITapGestureRecognizer *singleTapGestureRecognizer = [[UITapGestureRecognizer alloc]
//                                                          initWithTarget:self action:@selector(handleTapGestureAction:)];
//    singleTapGestureRecognizer.cancelsTouchesInView = NO;
//    singleTapGestureRecognizer.delegate = self;
//    [MassgeWebView addGestureRecognizer:singleTapGestureRecognizer];
    

    bgheadview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, Dev_ScreenWidth, 90+(_textFontSize-13))];
    [_bgscrollView addSubview:bgheadview];


    
    UILabel *labelTitle = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, Dev_ScreenWidth-20, 60+(_textFontSize-13))];
    labelTitle.font = [UIFont boldSystemFontOfSize:18+(_textFontSize-13)];  //UILabel的字体大小
    labelTitle.numberOfLines = 0;  //必须定义这个属性，否则UILabel不会换行
    labelTitle.textColor = RGBCOLOR(0, 0, 147);
    labelTitle.textAlignment = NSTextAlignmentLeft;  //文本对齐方式
    //[labelTitle setBackgroundColor:[UIColor redColor]];
    labelTitle.text =self.Title_massge ;
    [bgheadview addSubview:labelTitle];
    

    
    UILabel *labelReleaseDate = [[UILabel alloc] initWithFrame:CGRectMake(10, labelTitle.bottom, Dev_ScreenWidth-20, 20+(_textFontSize-13))];
    labelReleaseDate.font = [UIFont boldSystemFontOfSize:12+(_textFontSize-13)];  //UILabel的字体大小
    labelReleaseDate.numberOfLines = 1;  //必须定义这个属性，否则UILabel不会换行
    labelReleaseDate.textColor = [UIColor grayColor];
    labelReleaseDate.textAlignment = NSTextAlignmentLeft;  //文本对齐方式
    //[labelReleaseDate setBackgroundColor:[UIColor greenColor]];
    labelReleaseDate.text = self.ReleaseDate;
    [bgheadview addSubview:labelReleaseDate];
    
    
/***************************************手势侧滑测试******************************/
//    
//   UIView  *viewLeft = [UIView alloc]initWithFrame:CGRectMake(-Dev_ScreenWidth, 0, Dev_ScreenWidth, <#CGFloat height#>)
//    snakeImageView.frame = CGRectMake(50, 50, 100, 160);
    
    UIPanGestureRecognizer *panGestureRecognizer = [[UIPanGestureRecognizer alloc]
                                                    initWithTarget:self
                                                    action:@selector(handlePan:)];
    [_bgscrollView addGestureRecognizer:panGestureRecognizer];
    panGestureRecognizer.delegate =self;
  
//
//    self.navigationController.interactivePopGestureRecognizer.delegate = self;
//      self.navigationController.interactivePopGestureRecognizer.enabled = YES;
//    
    

}
- (void) handlePan:(UIPanGestureRecognizer*) recognizer
{
   
    CGPoint translation = [recognizer translationInView:self.view];
    
    if (translation.x > 100 && translation.y <50 && translation.y>-50)
    {
        [self.navigationController popViewControllerAnimated:YES];
    }
    
    NSLog(@"--------------------------x---> %lf",translation.x);
     NSLog(@"---------y----> %lf",translation.y);
    
//    recognizer.view.center = CGPointMake(recognizer.view.center.x + translation.x,
//                                         recognizer.view.center.y + translation.y);
//    [recognizer setTranslation:CGPointZero inView:self.view];
    
}




-(BOOL)gestureRecognizer:(UIGestureRecognizer*)gestureRecognizer shouldReceiveTouch:(UITouch*)touch {
    
    
    return YES;
    
}



- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{

    if ([gestureRecognizer isKindOfClass:[UIPanGestureRecognizer class]])
           {
                  return YES;
              }
        else
           {
                 return  NO;
            }



}


//#pragma mark - UIGestureRecognizerDelegate
//
//- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
//{
//    return YES;
//}
//
//- (void)handleTapGestureAction:(UITapGestureRecognizer *)gesture
//{
//    CGPoint curPoint = [gesture locationInView:MassgeWebView];
//    NSString *imgURL = [NSString stringWithFormat:@"document.elementFromPoint(%f, %f).src", curPoint.x, curPoint.y];
//    
//    NSString *urlToSave = [MassgeWebView stringByEvaluatingJavaScriptFromString:imgURL];
//    
//    if (!StringIsEmpty(urlToSave))
//    {
//        HXLog(@"%@", urlToSave);
//   
//        HXWebImageView *webImageView = [[HXWebImageView alloc] initWebImageViewWithImageUrl:urlToSave];
//        [webImageView show];
//    }
//}


#pragma mark webview
- (BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType {
   if(navigationType == UIWebViewNavigationTypeLinkClicked)
   {
       return NO;//禁止点击超链接
   }
    return YES;
    
    
//    UIWebViewNavigationTypeLinkClicked，用户触击了一个链接。
//    UIWebViewNavigationTypeFormSubmitted，用户提交了一个表单。
//    UIWebViewNavigationTypeBackForward，用户触击前进或返回按钮。
//    UIWebViewNavigationTypeReload，用户触击重新加载的按钮。
//    UIWebViewNavigationTypeFormResubmitted，用户重复提交表单
//    UIWebViewNavigationTypeOther，发生其它行为。
}

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    
    
    NSString *htmlHeight = [MassgeWebView stringByEvaluatingJavaScriptFromString:@"document.body.scrollHeight"];
    //设置高度
    MassgeWebView.frame =CGRectMake(0, bgheadview.bottom, Dev_ScreenWidth,[htmlHeight floatValue]+10);
    _bgscrollView.contentSize = CGSizeMake(Dev_ScreenWidth,[htmlHeight floatValue]+bgheadview.bottom);
}




- (void)scrollViewDidScroll:(UIScrollView *)scrollView;
{
  if(scrollView == MassgeWebView.scrollView)
  {
      //bgheadview.frame = CGRectMake(0, -scrollView.contentOffset.y,Dev_ScreenWidth, 80);
     // MassgeWebView.frame = CGRectMake(MassgeWebView.frame.origin.x, MassgeWebView.frame.origin.y-scrollView.contentOffset.y, MassgeWebView.frame.size.width, MassgeWebView.frame.size.width);
  }
    
    
//NSLog(@"ContentOffset  x is  %f,yis %f",scrollView.contentOffset.x,scrollView.contentOffset.y);
    
    
}

#pragma  mark 字体替换 确认代理
-(void)sizeFontNumber
{
    [_bgscrollView removeFromSuperview];
    [self rightAndMassgeForFantion];
    
//    //拿到设置字体大小设置
//    NSUserDefaults *UserDefaultSize =[NSUserDefaults standardUserDefaults];
//    _textFontSize = [UserDefaultSize floatForKey:YZZX_Font_Size];
//    NSString *jsString = [[NSString alloc] initWithFormat:@"document.getElementsByTagName('body')[0].style.webkitTextSizeAdjust= '%lu%%'",(unsigned long)_textFontSize];
//    
//    [MassgeWebView stringByEvaluatingJavaScriptFromString:jsString];
   
}



#pragma  mark 字体和评论弹出窗口  button点击方法
-(void)TabbarSelectorFantion:(UIControl *)tabcontrol
{

    if(tabcontrol.tag ==0)
    {
         /***********************************以下为调节Webveiw字体大小UI****************************/
        
        
        MassgeTheFont *viewfont = [[MassgeTheFont alloc]initWithViewFont:[UIApplication sharedApplication].keyWindow.bounds];
        [[UIApplication sharedApplication].keyWindow addSubview:viewfont];
        viewfont.SizeDelegat = self;
        
        
    }else if(tabcontrol.tag ==1)
    {
    /***********************************以下为跳转评论页面****************************/
    
        CommentListModelVC *commentlistVC =[[CommentListModelVC alloc]initWithDatadic:self.dicDataComm];
        [self.navigationController pushViewController:commentlistVC animated:YES];
    
    }


}



#pragma  mark 报名  咨询
-(void)AdvisorySelectorFantion:(UIControl *)tabcontrol
{
    
    if(tabcontrol.tag ==0)
    {
        /***********************************以下为调节Webveiw字体大小UI****************************/

        if(![[XSZ_UICommon useridChangUaerdfLoginBoolString]isEqualToString:@""])
        {
            AdvisoryForVC  *advVC = [[AdvisoryForVC alloc]init];
            advVC.DataMassgeModel = self.DataMassgeModel;
            [self.navigationController pushViewController:advVC animated:YES];
        }else if ([[XSZ_UICommon useridChangUaerdfLoginBoolString]isEqualToString:@""])
        {
            LoginViewController  *LoginView =[[LoginViewController alloc]init];
            LoginView.Viewdegat =self.Viewdegat;
            [self.navigationController pushViewController:LoginView animated:YES];
        }

        
    }else if(tabcontrol.tag ==1)
    {
        /***********************************以下为跳转评论页面****************************/
        
//        CommentListModelVC *commentlistVC =[[CommentListModelVC alloc]initWithDatadic:self.dicDataComm];
//        [self.navigationController pushViewController:commentlistVC animated:YES];
        

        if(![[XSZ_UICommon useridChangUaerdfLoginBoolString]isEqualToString:@""])
        {
            ActivitiesEntranceVC  *ActivitiesVC =[[ActivitiesEntranceVC alloc]init];
            ActivitiesVC.CreatID = self.DataMassgeModel.CateId;
            [self.navigationController pushViewController:ActivitiesVC animated:YES];
            
        }else if ([[XSZ_UICommon useridChangUaerdfLoginBoolString]isEqualToString:@""])
        {
            LoginViewController  *LoginView =[[LoginViewController alloc]init];
            LoginView.Viewdegat =self.Viewdegat;
            [self.navigationController pushViewController:LoginView animated:YES];
        }

        
    }
    
    
}




- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    [self PermissionsView];
//     [self rightAndMassgeForFantion];
    
    
}
- (void)PermissionsView
{
  
    
    
    //列表请求
    NSDictionary* dicParams = [NSDictionary dictionaryWithObjectsAndKeys:
                               [XSZ_UICommon useridChangUaerdfLoginBoolString],    @"user_id",
                               @"1",    @"site_id",
                               self.DataMassgeModel.CateId,    @"cate_id",
                               nil];
    

    
    if (_httpRequest == nil)
    {
        _httpRequest = [[HXHttpRequest alloc] init];
        _httpRequest.delegate = self;
        
        
        
    }
    [_httpRequest requestForParams:dicParams andMethod:YZ_CATEGORY_CHECK andTag:1000];//@"system.time"];//@"category.list"];
    
}



#pragma mark  如果有权限则执行 请求
- (void)rightAndMassgeForFantion
{
    self.RefreshBut = [UIButton buttonWithType:UIButtonTypeCustom];
    self.RefreshBut.frame = CGRectMake(Dev_ScreenWidth-32, 64-32, 32, 32);
    [self.RefreshBut setImage:[UIImage imageNamed:@"action_refresh"] forState:UIControlStateNormal];
    [self.RefreshBut setImage:[UIImage imageNamed:@"action_refresh_h"] forState:UIControlStateHighlighted];
    // self.RefreshBut.hidden =YES;

    [self.RefreshBut addTarget:self action:@selector(ButMenuBseletor) forControlEvents:UIControlEventTouchUpInside];


    UIBarButtonItem *negativeSpacerRight = [[UIBarButtonItem alloc]

                                            initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace

                                            target:nil action:nil];
    
        /**
    
         *  width为负数时，相当于btn向右移动width数值个像素，由于按钮本身和边界间距为5pix，所以width设为-5时，间距正好调整
    
         *  为0；width为正数时，正好相反，相当于往左移动width数值个像素
    
         */
    
        negativeSpacerRight.width = -12;
    
        UIBarButtonItem *rightBarBtItem = [[UIBarButtonItem alloc] initWithCustomView:self.RefreshBut];
    
        self.navigationItem.rightBarButtonItems = [NSArray arrayWithObjects:negativeSpacerRight, rightBarBtItem, nil];
    
    
    
    
    
    //查询
    
    
    
    if([YZFMDB getAllPeople:self.DataMassgeModel.id_massge]!=nil)
    {
        NSMutableArray  *arrydatasFmdb = [YZFMDB getAllPeople:self.DataMassgeModel.id_massge];
        NSMutableDictionary  *  dic = [arrydatasFmdb objectAtIndex:0];
        
        self.Content                    = [dic objectForKey:@"Content"];
        self.Title_massge               = [dic objectForKey:@"Title"];
        self.id_massge                  = [dic objectForKey:@"id"];
        self.ReleaseDate                = [dic objectForKey:@"ReleaseDate"];
        
//        
//        NSNumber *idmassge = [dic objectForKey:@"id"];
//        self.id_massge                  = [idmassge  stringValue];
        
        
        [_bgscrollView removeFromSuperview];
        [self creatViewAndContorller];
        self.dicDataComm = dic;
    
    }else if ([YZFMDB getAllPeople:self.DataMassgeModel.id_massge]==nil)
    {

    
        NSMutableArray *arrykey = [[NSMutableArray alloc]init];
        [arrykey addObject:self.DataMassgeModel.id_massge];
        
        
        //列表请求
        NSDictionary* dicParams = [NSDictionary dictionaryWithObjectsAndKeys:
                                   [XSZ_UICommon useridChangUaerdfLoginBoolString],    @"user_id",
                                   @"1",    @"site_id",
                                   arrykey, @"ids"
                                   ,nil];
        
        
        if (_httpRequest == nil)
        {
            _httpRequest = [[HXHttpRequest alloc] init];
            _httpRequest.delegate = self;
            
            
            
        }
        [_httpRequest requestForParams:dicParams andMethod:YZ_ARTICLE_QUERY andTag:1001];//@"system.time"];//@"category.list"];
        
    }
    
 
}



//刷新
-(void)ButMenuBseletor
{
    
    
    NSMutableArray *arrykey = [[NSMutableArray alloc]init];
    [arrykey addObject:self.DataMassgeModel.id_massge];

    //列表请求
    NSDictionary* dicParams = [NSDictionary dictionaryWithObjectsAndKeys:
                               [XSZ_UICommon useridChangUaerdfLoginBoolString],    @"user_id",
                               @"1",    @"site_id",
                               arrykey, @"ids"
                               ,nil];
    
    
    if (_httpRequest == nil)
    {
        _httpRequest = [[HXHttpRequest alloc] init];
        _httpRequest.delegate = self;
        
        
        
    }
    [_httpRequest requestForParams:dicParams andMethod:@"article.query"andTag:1001];//@"system.time"];//@"category.list"];
    
    [MBProgressHUD showHUDAddedTo:self.view animated:YES];




}

#pragma mark - HXHttpRequestDelegate  代理

- (void)requestFinished:(NSString *)responseString andStatusCode:(int)statusCode andTag:(NSInteger)tag
{
    
    
    [MBProgressHUD hideHUDForView:self.view animated:YES];
    
    //tableview列表数据
    if(tag == 1001)
    {
        //  NSLog(@"---------------->>>> %@",responseString);
        
        NSDictionary *dic = [[NSDictionary alloc]init];
        dic = [JsonUtil jsonToDic:responseString];
        
        // NSLog(@"---------------->>>> \n%@",dic);
        
        NSString * strs = dic[@"data"];
        
        NSDictionary *dics =[JsonUtil jsonToDic:strs];
        
       
        NSArray *arryy =(NSArray *)dics;
  
       // NSLog(@"---------00------->>>> %@",arryy);
        
        NSDictionary *dicuu = [arryy objectAtIndex:0];
        
        self.Content                    = [dicuu objectForKey:@"Content"];
        self.Image                      = [dicuu objectForKey:@"Image"];
        self.LastChangedTime            = [dicuu objectForKey:@"LastChangedTime"];
        self.Order                      = [dicuu objectForKey:@"Order"];
        
        //时间转换
        NSDateFormatter *dateformatter = [[NSDateFormatter alloc] init];
        [dateformatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
        NSDate *date = [dateformatter dateFromString:[dicuu objectForKey:@"ReleaseDate"]];
        [dateformatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
        NSString *strtime = [dateformatter stringFromDate:date];
        
        self.ReleaseDate                = strtime;
        self.Source                     = [dicuu objectForKey:@"Source"];
        self.Subtitle                   = [dicuu objectForKey:@"Subtitle"];
        self.Summary                    = [dicuu objectForKey:@"Summary"];
        self.Title_massge               = [dicuu objectForKey:@"Title"];
        self.id_massge                  = [[dicuu objectForKey:@"id"] stringValue];
               
        
        //缓存数据
        [YZFMDB insertMassge:self.id_massge Data:self.Content Title:self.Title_massge Time:self.ReleaseDate];
        
        [_bgscrollView removeFromSuperview];
        [self creatViewAndContorller];
        NSMutableDictionary  *dicdata = [[NSMutableDictionary alloc]init];
        [dicdata setObject:self.Content forKey:@"Content"];
        [dicdata setObject:self.Title_massge forKey:@"Title"];
        [dicdata setObject:self.id_massge forKey:@"id"];
        [dicdata setObject:self.ReleaseDate forKey:@"ReleaseDate"];
    

        self.dicDataComm = dicdata;
        
    }else if(tag == 1000)
    {
        //  NSLog(@"---------------->>>> %@",responseString);
        
        NSDictionary *dic = [[NSDictionary alloc]init];
        dic = [JsonUtil jsonToDic:responseString];
        
        // NSLog(@"---------------->>>> \n%@",dic);
        
        NSString * strs = dic[@"data"];
        
        NSDictionary *dics =[JsonUtil jsonToDic:strs];

        if([[dics objectForKey:@"result"] boolValue])
        {
            [_bgscrollView removeFromSuperview];
            [self rightAndMassgeForFantion];
        
        }else if (![[dics objectForKey:@"result"] boolValue])
        {
            [_bgscrollView removeFromSuperview];
            viewbg  =[[UIView alloc]initWithFrame:CGRectMake(0, 0, Dev_ScreenWidth, Dev_ScreenHeight-64)];
            [self.view addSubview:viewbg];
           
            
            
            UIImageView  *Viewiamge =[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"sorry.jpg"]];
            Viewiamge.frame =CGRectMake(5, 40, Dev_ScreenWidth-10, (Dev_ScreenWidth-10)*350/550);
            [viewbg addSubview:Viewiamge];
            
            
            UILabel *labelTitle = [[UILabel alloc] initWithFrame:CGRectMake(5, Viewiamge.bottom+10, Dev_ScreenWidth-10, 40)];
            labelTitle.font = [UIFont boldSystemFontOfSize:14];  //UILabel的字体大小
            labelTitle.numberOfLines = 0;  //必须定义这个属性，否则UILabel不会换行
            labelTitle.textColor = RGBCOLOR(119, 119, 119);
            labelTitle.textAlignment = NSTextAlignmentLeft;  //文本对齐方式
            //[labelTitle setBackgroundColor:[UIColor redColor]];
            labelTitle.text =[dics objectForKey:@"message"] ;
            [viewbg addSubview:labelTitle];
            

            
            UIButton *bottomButtonLoin = [UIButton buttonWithType:UIButtonTypeCustom];
            bottomButtonLoin.tag = 2014 ;
            bottomButtonLoin.frame = CGRectMake(Dev_ScreenWidth/2-50, labelTitle.bottom +10, 50, 44);
            [bottomButtonLoin addTarget:self action:@selector(tabBarButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
            [bottomButtonLoin.layer setMasksToBounds:YES];
            [bottomButtonLoin.layer setCornerRadius:2]; //设置矩圆角半径
            [bottomButtonLoin.layer setBorderWidth:0];   //边框宽度
            [bottomButtonLoin setTitle:@"登录" forState:UIControlStateNormal];
            [bottomButtonLoin setTintColor:[UIColor whiteColor]];
            bottomButtonLoin.backgroundColor =RGBCOLOR(38, 102, 221);
            [viewbg addSubview:bottomButtonLoin];
            
            
            UIButton *bottomButton = [UIButton buttonWithType:UIButtonTypeCustom];
            bottomButton.tag = 2015 ;
            bottomButton.frame = CGRectMake(Dev_ScreenWidth/2+10, labelTitle.bottom +10,80, 44);
            [bottomButton addTarget:self action:@selector(tabBarButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
            [bottomButton.layer setMasksToBounds:YES];
            [bottomButton.layer setCornerRadius:2]; //设置矩圆角半径
            [bottomButton.layer setBorderWidth:0];   //边框宽度
            [bottomButton setTitle:@"联系客服" forState:UIControlStateNormal];
            [bottomButton setTintColor:[UIColor whiteColor]];
            bottomButton.backgroundColor =RGBCOLOR(38, 102, 221);//RGBCOLOR(252, 78, 125);
            [viewbg addSubview:bottomButton];
            
        
        }
        
    }

    
    
}

- (void)requestFailed:(NSError *)error andTag:(NSInteger)tag
{

    
    
}

- (void)tabBarButtonClicked:(UIButton *)but
{
    if(but.tag == 2014)
    {
        LoginViewController   *LoginView = [[LoginViewController alloc]init];
        LoginView.Viewdegat =self.Viewdegat;
        [self.navigationController pushViewController:LoginView animated:YES];
        
    }else if(but.tag == 2015)
    {
        ContactViewController   *ContactView = [[ContactViewController alloc]init];
        [self.navigationController pushViewController:ContactView animated:YES];
    
    }
      

}




@end
